package sanrenxing.dayEnd.backRepertoryTotal.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.tags.EditorAwareTag;
import sanrenxing.dayEnd.backRepertoryTotal.domain.RepertoryTotal;
import sanrenxing.dayEnd.backRepertoryTotal.service.RepertoryTotalService;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/RepertoryTotalController")
public class RepertoryTotalController {

    //注入业务处理对象
    @Autowired
    private RepertoryTotalService repertoryTotalService;

    @GetMapping("/method")
    public Map<String,Object> queryAll(HttpServletRequest request){
        //创建一个map集合用于向前端发送数据
        Map<String, Object> map = new HashMap<String, Object>();
        //设置状态码为0
        map.put("code",0);
        //设置响应的信息 " "
        map.put("msg","");
        //发送总行数为5
        map.put("count",5);
        //发送数据
        map.put("data",repertoryTotalService.getList(request));
        return map;
    }

    @PutMapping("/method")
    public String repertory(){
        //调用方法，点击统计应当更新五大库存当中的数据
        return repertoryTotalService.updateRepertory()?"success":"fail";
    }

}
